import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/framework.dart';

class RoundedButton extends StatelessWidget {
  final String text;
  final Function() press;
  final Color? color,textColor;
  const RoundedButton({Key? key,
   required this.text,
   required this.press,
   this.color, 
   this.textColor}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    return Container(
      margin: EdgeInsets.symmetric(vertical: 10),
      width: size.width * 0.8,
      child:ClipRRect(
        borderRadius: BorderRadius.circular(29),
        child: FlatButton(
          padding: EdgeInsets.symmetric(vertical: 20,horizontal: 40),
          onPressed: press, 
          child: Text(
            text,
            style: TextStyle(color: textColor),
          )),
      )
    );
    
    
  }

  //  //注册
  // void SignUp(BuildContext context) async {
  //   String loginURL = baseURL+'/user/register';
  //   Dio dio = new Dio();

  //   var response = await dio.post(
  //       loginURL+"?token="+token,
  //       data: {'email': email, 'password': password,"username":username}
  //   );

  //   print('Respone ${response.statusCode}');
  //   print(response.data);

  //   //前台似乎很方便? 因为后台已经处理了大部分逻辑! shit, 我是个全栈, 都由我来做! shit 我叫屈叼叼 是个大佬菜鸡
  //   if (response.statusCode == 200) {
  //     Fluttertoast.showToast(
  //         msg: response.data,
  //         gravity: ToastGravity.CENTER,
  //         textColor: Colors.grey);

  //     if(response.data=="sucess"){
  //       Navigator.pop(context);
  //       Navigator.pop(context);
  //       Navigator.push(context, MaterialPageRoute(builder: (context) => home(email: email,)));
  //     }
  //   }
  //   else{
  //     showToast("服务器或网络错误!");
  //   }
  // }

  // //发生验证码
  // void send() async {
  //   String sendURL = baseURL+"/user/send";
  //   Dio dio = new Dio();
  //   print("username:"+username);
  //   var response = await dio.post(
  //       sendURL,
  //       data: {'email': email, 'password': password,"username":username}
  //   );
  //   print('Respone ${response.statusCode}');
  //   print(response.data);
  //   //成功发生送验证码
  //   if (response.statusCode == 200) {
  //     Fluttertoast.showToast(
  //         msg: response.data,
  //         gravity: ToastGravity.CENTER,
  //         textColor: Colors.grey);
  //     token=response.data.toString();
  //   }
  //   else{
  //     showToast("服务器或网络错误!");
  //   }
  // }
}